<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>上菜</title>
</head>
<body>
<%
//加载驱动       
Class.forName("org.mariadb.jdbc.Driver");

// 数据库连接信息
String dbURL = "jdbc:mariadb://10.220.140.102:3366/studb11";
String dbUser = "stua";
String dbPassword = "zHZUA65r";




// 建立连接
Connection conn = DriverManager.getConnection(dbURL, dbUser, dbPassword);
Statement stmt=conn.createStatement();
ResultSet rs = stmt. executeQuery("select*from shoppingcar");
String dish_name = request.getParameter("name");


        if (rs.next()) {
            
            String roomSql = "UPDATE shoppingcar SET status = '已完成'  WHERE name='"+dish_name+"' LIMIT 1";
            
            Statement roomStmt = conn.createStatement();
            int rowsAffected = roomStmt.executeUpdate(roomSql);
            
            if (rowsAffected > 0 ) {
                out.println("上菜成功");
            } else {
                out.println("上菜不成功");
            }
        } 

%>

</body>
</html>